<!--
 * @Author: wrh123 482597539@qq.com
 * @Date: 2024-01-16 10:09:00
 * @LastEditors: wrh123 482597539@qq.com
 * @LastEditTime: 2024-01-25 17:26:59
 * @FilePath: /vue-admin/src/views/Profit/components/addRefundList.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
  <div class="refundList">
    <el-dialog title="盈利申请" :visible="dialogVisible" width="30%" :before-close="handleClose">
      <div v-if="dialogRow.profitMethod === 1" style="margin-left: 8%;line-height: 30px;margin-bottom: 20px">
        <div>银行账号：{{ queryFrom.bankAccountNumber }}</div>
        <div>银行名称：{{ queryFrom.bankName }}</div>
        <div>银行分行：{{ queryFrom.bankStreet }}</div>
        <div>用户姓名：{{ queryFrom.beneficiaryName }}</div>
        <!-- <div> 银行信息显示在此处</div> -->
      </div>
      <div v-if="dialogRow.profitMethod === 2" style="margin-left: 8%;line-height: 30px;margin-bottom: 20px">
        <!-- <div>
          电子货币：{{
            queryFrom.crypto === 1 ? 'Bitcoin' : queryFrom.crypto === 2 ? 'Ethereum' : queryFrom.crypto === 3 ? 'Litecoin'
              : queryFrom.crypto === 4 ? 'Ripple' : queryFrom.crypto === 5 ? 'USDT' : ''
          }}
        </div> -->
        <div>加密货币：{{ queryFrom.crypto }}</div>
        <div>地址：{{ queryFrom.cryptoAddress }}</div>
        <div>网络：{{ queryFrom.network }}</div>
      </div>
      <el-form ref="ruleForm" :model="ruleForm" :rules="rules" label-width="100px">
        <el-form-item prop="profitResult" label="处理结果">
          <el-select v-model="ruleForm.profitResult" size="mini">
            <el-option label="同意" :value="2" />
            <el-option label="驳回" :value="3" />
          </el-select>
        </el-form-item>
        <!--        <el-form-item prop="withdrawMoney" label="金额">-->
        <!--          <el-input v-model="ruleForm.withdrawMoney" size="mini" />-->
        <!--        </el-form-item>-->
        <el-form-item v-if="ruleForm.profitResult === 3" prop="refuseReason" label="备注">
          <el-input v-model="ruleForm.profitRemark" size="mini" />
        </el-form-item>
        <!--        <el-form-item prop="withdrawType" label="提现类型">-->
        <!--          <el-select v-model="ruleForm.withdrawType" size="mini">-->
        <!--            <el-option-->
        <!--              label="盈利体现"-->
        <!--              :value="1"-->
        <!--            />-->
        <!--            <el-option-->
        <!--              label="报名费体现"-->
        <!--              :value="2"-->
        <!--            />-->
        <!--          </el-select>-->
        <!--        </el-form-item>-->
        <el-form-item>
          <el-row type="flex" justify="end" style="margin-top: 10px;">
            <el-button size="mini" @click="handleClose">否</el-button>
            <el-button size="mini" type="primary" @click="btnOK">是</el-button>
          </el-row>
        </el-form-item>
      </el-form>
    </el-dialog>
  </div>
</template>

<script>
import { handleRefund, getWithdrawList } from '@/api/Profit'

export default {
  name: 'VueAdminAddRefundList',
  props: {
    dialogVisible: {
      default: false,
      type: Boolean
    },
    dialogRow: {
      type: Object,
      default: null
    }
  },
  data() {
    return {
      ruleForm: {
        profitResult: 2,
        profitRemark: null,
        id: null,
        withdrawMoney: '',
        withdrawType: 1
      },
      queryFrom: {},
      rules: {
        profitResult: [
          { required: true, message: '处理结果不可以为空', trigger: 'change' }
        ],
        profitRemark: [
          { required: true, message: '拒绝原因不可以为空', trigger: 'blur' }
        ],
        withdrawMoney: [
          { required: true, message: '提现金额不可以为空', trigger: 'blur' }
        ],
        withdrawType: [
          { required: true, message: '提现类型不可以为空', trigger: 'change' }
        ]
      }
    }
  },
  watch: {
    dialogRow(old, val) {
      console.log(old, 'old')
      this.ruleForm.id = old.id
    }
  },
  mounted() {
    console.log(this.props.dialogRow, "1234565")
  },

  methods: {
    // 取消
    async handleClose() {
      this.ruleForm = {
        withdrawalYesAndNo: 0,
        refuseReason: '',
        id: '',
        // withdrawMoney: '',
        // withdrawType: 1
      }
      await this.$refs.ruleForm.resetFields()
      this.$emit('update:dialogVisible', false)
    },
    // 确定
    async btnOK() {
      await this.$refs.ruleForm.validate()
      await handleRefund(this.ruleForm)
      this.$message.success('操作成功')
      this.$emit('refresh')
      this.handleClose()
    },
    // 回显提现信息
    async getWithdrawInfo(row) {
      const res = await getWithdrawList(row.id)
      console.log(res, 'res')
      this.queryFrom = res
    }
  }
}
</script>

<style lang="scss" scoped></style>
